package customfields;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
import beans.Message;

public class MessageField extends VerticalFieldManager{
	
	public MessageField(Message m){
		super(Field.FIELD_HCENTER | Field.USE_ALL_WIDTH);
		
		HorizontalFieldManager header = new HorizontalFieldManager();
		
		WhiteLabelField autor = new WhiteLabelField(m.getUser(), Field.FIELD_LEFT);
		header.add(autor);
		WhiteLabelField date = new WhiteLabelField(m.getDate(), Field.FIELD_RIGHT);
		this.add(date);
		this.add(header);
		
		LabelField content = new LabelField(m.getMessage(), Field.USE_ALL_WIDTH);
		content.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 150));
		this.add(content);
		
		this.setBackground(BackgroundFactory.createSolidTransparentBackground(Color.WHITE, 50));
		this.setMinimalWidth(Display.getWidth());
		this.setPadding(10, 10, 10, 10);
	}

}
